<%@ Language=VBScript %>
<% Option Explicit %>
<% Response.Buffer = true %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<%
   Dim strQry, strName, arrQry, arrValues, x
   Dim Recipient, FromVar, DefFrom, DefSubject, DefRedirect, EOL
   Dim Body, objMailer
   
   strQry=Request.Form
   
   '<===============-------- Start of User Defined Variables --------================>
   
   Recipient = "rrc@redemptoristretreat.org"		'Where the message goes
   DefFrom = "WebBot@redemptoristretreat.org"		'Used if no response email
   DefSubject = "Reservation Submission"			'Used if form doesn't have an element named subject
   DefRedirect = "ThankYou.htm"						'Used if form doesn't have an element named redirect
  
   ' <===============-------- End of User Defined Variables --------================>
   
   if len(Request.Form("Email"))>4 then
      DefFrom = Request.Form("Email")
   end if
   
   if len(Request.Form("Subject"))>0 then
      DefSubject = Request.Form("Subject")
   end if
   
   if len(Request.Form("Redirect"))>0 then
      DefRedirect = Request.Form("Redirect")
   end if
   
   if not(ValidEmail(Recipient)) then
      Response.Write " for Recipient<BR>"
      Response.End
   end if
   
   if not(ValidEmail(DefFrom)) then
      Response.Write " for sender (" & DefFrom & ")<BR>"
      Response.End
   end if
   
   'If we made it this far everything looks OK  so its time to process the
   'Form Elements and send the email
   EOL = chr(10) & chr (13)
   
   arrQry = split(strQry,"&")
   Body = string(40,"-") & chr(10) & chr(13)
   'for x = lbound(arrQry) to ubound(arrQry)
   '   arrValues = split(arrQry(x),"=")
   '   Body = Body & arrValues(0) & " = " & Request.Form(arrValues(0)) & chr(10) & chr(13)
   'next
   
   Body = Body & "Retreat: " & Request.Form("RetreatName") & EOL
   Body = Body & "Name: " & Request.Form("Name") & EOL
   Body = Body & "Address: " & Request.Form("Address") & EOL
   Body = Body & "City: " & Request.Form("City") & EOL
   Body = Body & "State: " & Request.Form("State") & EOL
   Body = Body & "Zip: " & Request.Form("Zip") & EOL
   Body = Body & "Phone: " & "(" & Request.Form("phone_AC") & ") " & Request.Form("phone_EX") & " - " & Request.Form("phone_SFX") & EOL
   Body = Body & "email: " & Request.Form("email") & EOL & EOL
   
   Body = Body & "Comments:" & EOL
   Body = Body & Request.Form("Comments") & EOL
   
   
   
   'Response.Write Body
   Set objMailer = CreateObject("CDONTS.Newmail")
      objMailer.From = DefFrom
      objMailer.To = Recipient
      objMailer.Subject = DefSubject
      objMailer.Body = Body
      objMailer.Send
   Set objMailer = Nothing
      
   if DefRedirect = "" then
      Response.Write "<H1 align=center>Thank You for your submission</H1>"
      Response.Write "<HR>"
      Response.Write "You should be hearing from us within 72 hours<BR>"
      Response.Write "<P>&nbsp;<P>&nbsp;<P>&nbsp;<P>&nbsp;"
   else 
      Response.Redirect DefRedirect
   end if
   
%>

<%
   Function ValidEmail(Email)
      ValidEmail = true
      Dim Temp,Temp2
      if len(Email) > 100 then
         Response.Write "<br>Email address too long (" & Email & ")"
         ValidEmail = false
         Exit Function
      end if
      Email = LCase(Email)
      Temp = Split(Email,"@")
      if ubound(Temp) < 1 then
         Response.Write "<br>Email address not valid (" & Email & ")"
         ValidEmail = false
         Exit Function
      end if
      Temp2 = Split(Temp(1),".",-1,1)
      if ubound(Temp2) < 1 then
         Response.Write "<br>Email address not valid (" & Email & ")"
         ValidEmail = false
      end if
   End Function
%>

<BODY>
<P>&nbsp;</P>

</BODY>
</HTML>
